

#ifndef OSD_H_
#define OSD_H_
#include <stdlib.h>
#include "GUI.h"
#include <time.h>
#include "platform.h"
#include <sys/statfs.h>
#include <stdio.h>
#include <stdint.h>
#include "i2cled.h"
#ifndef GUI_FLASH
	#define GUI_FLASH
#endif

/*
//Standard colors
#define GUI_BLUE          0xFF0000
#define GUI_GREEN         0x00FF00
#define GUI_RED           0x0000FF
#define GUI_CYAN          0xFFFF00
#define GUI_MAGENTA       0xFF00FF
#define GUI_YELLOW        0x00FFFF
#define GUI_LIGHTBLUE     0xFF8080
#define GUI_LIGHTGREEN    0x80FF80
#define GUI_LIGHTRED      0x8080FF
#define GUI_LIGHTCYAN     0xFFFF80
#define GUI_LIGHTMAGENTA  0xFF80FF
#define GUI_LIGHTYELLOW   0x80FFFF
#define GUI_DARKBLUE      0x800000
#define GUI_DARKGREEN     0x008000
#define GUI_DARKRED       0x000080
#define GUI_DARKCYAN      0x808000
#define GUI_DARKMAGENTA   0x800080
#define GUI_DARKYELLOW    0x008080
#define GUI_WHITE         0xFFFFFF
#define GUI_LIGHTGRAY     0xD3D3D3
#define GUI_GRAY          0x808080
#define GUI_DARKGRAY      0x404040
#define GUI_BLACK         0x000000
#define GUI_BROWN         0x2A2AA5

//draw function

int  GUI_BMP_Draw         (const void * pFileData, int x0, int y0);
int  GUI_BMP_GetXSize     (const void * pFileData);
int  GUI_BMP_GetYSize     (const void * pFileData);
void GUI_Clear            (void);
void GUI_ClearRect        (int x0, int y0, int x1, int y1);
void GUI_ClearRectEx      (const GUI_RECT* pRect);
void GUI_DrawArc          (int x0, int y0, int rx, int ry, int a0, int a1);
void GUI_DrawBitmap       (const GUI_BITMAP GUI_UNI_PTR * pBM, int x0, int y0);
void GUI_DrawBitmapMag    (const GUI_BITMAP GUI_UNI_PTR * pBM, int x0, int y0, int XMul, int YMul);
void GUI_DrawBitmapEx     (const GUI_BITMAP GUI_UNI_PTR * pBitmap, int x0, int y0, int xCenter, int yCenter, int xMag, int yMag);
void GUI_DrawBitmapExp    (int x0, int y0, int XSize, int YSize, int XMul,  int YMul, int BitsPerPixel, int BytesPerLine, const U8 GUI_UNI_PTR * pData, const GUI_LOGPALETTE GUI_UNI_PTR * pPal);
void GUI_DrawCircle       (int x0, int y0, int r);                                                              //画圆
void GUI_DrawEllipse      (int x0, int y0, int rx, int ry);                                                     //画椭圆
void GUI_DrawGraph        (I16 *pay, int NumPoints, int x0, int y0);
void GUI_DrawGraphEx      (I16 *pay, int NumPoints, int x0, int y0, int Numerator, int Denominator);
void GUI_DrawHLine        (int y0, int x0, int x1);
void GUI_DrawLine         (int x0, int y0, int x1, int y1);
void GUI_DrawLineRel      (int dx, int dy);
void GUI_DrawLineTo       (int x, int y);
void GUI_DrawPie          (int x0, int y0, int r, int a0, int a1, int Type);
void GUI_DrawPixel        (int x, int y);
void GUI_DrawPoint        (int x, int y);
void GUI_DrawPolygon      (const GUI_POINT* pPoints, int NumPoints, int x0, int y0);
void GUI_DrawPolyLine     (const GUI_POINT* pPoints, int NumPoints, int x0, int y0);
void GUI_DrawFocusRect    (const GUI_RECT *pRect, int Dist);
void GUI_DrawRect         (int x0, int y0, int x1, int y1);                                                     //绘制矩形
void GUI_DrawRectEx       (const GUI_RECT *pRect);
void GUI_DrawVLine        (int x0, int y0, int y1);                                                             //绘制竖直线
void GUI_FillCircle       (int x0, int y0, int r);                                                              //绘制填充圆
void GUI_FillEllipse      (int x0, int y0, int rx, int ry);                                                     //绘制填充椭圆
void GUI_FillPolygon      (const GUI_POINT* pPoints, int NumPoints, int x0, int y0);
void GUI_FillRect         (int x0, int y0, int x1, int y1);
void GUI_FillRectEx       (const GUI_RECT* pRect);
void GUI_GetClientRect    (GUI_RECT* pRect);
int  GUI_GIF_Draw         (const void * pGIF, U32 NumBytes, int x0, int y0);
int  GUI_GIF_DrawEx       (const void * pGIF, U32 NumBytes, int x0, int y0, int Index);
int  GUI_GIF_GetComment   (const void * pGIF, U32 NumBytes, U8 * pBuffer, int MaxSize, int Index);
int  GUI_GIF_GetXSize     (const void * pGIF);
int  GUI_GIF_GetYSize     (const void * pGIF);
int  GUI_GIF_GetImageInfo (const void * pGIF, U32 NumBytes, GUI_GIF_IMAGE_INFO * pInfo, int Index);
int  GUI_GIF_GetInfo      (const void * pGIF, U32 NumBytes, GUI_GIF_INFO * pInfo);
void GUI_InvertRect       (int x0, int y0, int x1, int y1);
void GUI_MoveRel          (int dx, int dy);
void GUI_MoveTo           (int x, int y);
*/


//color is BGR format;
#define CONSOLE_DEBUG 					0
#define BACK_COLOR                      GUI_BLACK

#define OSD_INFO_PEN_COLOR				0xF0B000	//OSD文字信息颜色

#define MAIN_SELECT_BK_COLOR            0xF0B000	//淡蓝色，RGB=0X00B0F0,BGR=0xF0B000,
#define MAIN_SELECT_PEN_COLOR           GUI_WHITE   //0x00C0FF=橘黄色
#define MAIN_UNSELECT_BK_COLOR          0X352C23	//0x595959 =灰色, 0x5C1E1E=深蓝，0x421616 =墨蓝,0X503E2B=蓝灰-->0X2E241A-->0X241A10
#define MAIN_UNSELECT_PEN_COLOR         GUI_WHITE

#define MID_SELECT_BK_COLOR             0xF0B000	//0x595959
#define MID_SELECT_PEN_COLOR            GUI_WHITE   //0x00C0FF=橘黄色
#define MID_UNSELECT_BK_COLOR           0X3C3228	//0xF0B000
#define MID_UNSELECT_PEN_COLOR          GUI_WHITE

#define SUB_SELECT_BK_COLOR             0xF0B000	//0x595959
#define SUB_SELECT_PEN_COLOR            GUI_WHITE   //0x00C0FF=橘黄色
#define SUB_UNSELECT_BK_COLOR           0X463C2D	//0X352C23-->0X3C3228-->0X463C2D(深灰->浅灰过度）
#define SUB_UNSELECT_PEN_COLOR          GUI_WHITE 

extern GUI_CONST_STORAGE GUI_BITMAP bmtime_set;
extern GUI_CONST_STORAGE GUI_BITMAP bmled;
extern GUI_CONST_STORAGE GUI_BITMAP bmbrightness;
extern GUI_CONST_STORAGE GUI_BITMAP bmcolor_modify;
extern GUI_CONST_STORAGE GUI_BITMAP bmmirror;
extern GUI_CONST_STORAGE GUI_BITMAP bmenhance;
extern GUI_CONST_STORAGE GUI_BITMAP bmelec;
extern GUI_CONST_STORAGE GUI_BITMAP bmscale;
extern GUI_CONST_STORAGE GUI_BITMAP bmdefault;
extern GUI_CONST_STORAGE GUI_BITMAP bmsave;
extern GUI_CONST_STORAGE GUI_BITMAP bmphoto;
extern GUI_CONST_STORAGE GUI_BITMAP bmvideo1;
extern GUI_CONST_STORAGE GUI_BITMAP bmvideo2;

extern GUI_CONST_STORAGE GUI_BITMAP bmfreeze;
extern GUI_CONST_STORAGE GUI_BITMAP bmfreeze2;
extern GUI_CONST_STORAGE GUI_BITMAP bmfreeze3;
extern GUI_CONST_STORAGE GUI_BITMAP bmfreeze4;
extern GUI_CONST_STORAGE GUI_BITMAP bmimage;
extern GUI_CONST_STORAGE GUI_BITMAP bmimage2;
extern GUI_CONST_STORAGE GUI_BITMAP bmrecord1;
extern GUI_CONST_STORAGE GUI_BITMAP bmrecord2;
extern GUI_CONST_STORAGE GUI_BITMAP bmrecord3;
extern GUI_CONST_STORAGE GUI_BITMAP bmrecord4;
extern GUI_CONST_STORAGE GUI_BITMAP bmmwb1;
extern GUI_CONST_STORAGE GUI_BITMAP bmmwb2;
extern GUI_CONST_STORAGE GUI_BITMAP bmwarning1;
extern GUI_CONST_STORAGE GUI_BITMAP bmwarning2;
extern GUI_CONST_STORAGE GUI_BITMAP bmcopyfile1;
extern GUI_CONST_STORAGE GUI_BITMAP bmcopyfile2;

extern GUI_CONST_STORAGE GUI_BITMAP bmN_m1_0;
extern GUI_CONST_STORAGE GUI_BITMAP bmN_m1_1;
extern GUI_CONST_STORAGE GUI_BITMAP bmN_m1_0;
extern GUI_CONST_STORAGE GUI_BITMAP bmN_m1_1;
extern GUI_CONST_STORAGE GUI_BITMAP bmN_m1_0;
extern GUI_CONST_STORAGE GUI_BITMAP bmN_m1_1;
extern GUI_CONST_STORAGE GUI_BITMAP bmN_m1_0;

//时间设置
typedef struct time_stamp
{
    int year;
    int month;
    int day;
    int hour;
    int min;
    int second;
} time_stamp;

//图像设置
typedef struct osd_image_set_info
{
    int r;
    int g;
    int b;
    int enhance;
    int brightness;
    int saturate;
    int contrast;
    int temperature;
}osd_image_set_info;

//图像风格
typedef enum
{
    osd_mask_round = 1,
    osd_mask_right,
    osd_mask_acute,
    osd_mask_circular
} osd_mask_mode;

//图像缩放
typedef enum
{
    osd_rote_0 = 0,
    osd_rote_90,
    osd_rote_180,
    osd_rote_270
} osd_rote_mode;

//图像镜像
typedef enum
{
    osd_mirror_ud = 0,
    osd_mirror_lr,
    osd_mirror_both,
    osd_mirror_none                             //edwin add 20230323
} osd_mirror_mode;

//图像显示尺寸设置
typedef enum
{
    osd_scale_400x400 = 1,
    osd_scale_600x600,
    osd_scale_800x800,
    osd_scale_1000x1000
} osd_scale_mode;

//OSD led设置
typedef struct osd_led_level_info
{
    int led_status;
    int led_value;
}osd_led_level_info;

//OSD 摄像头连接信息
typedef enum
{
    osd_connect_std  = 1,
    osd_connect_shd,
    osd_connect_uvc,
    osd_connect_uhd
} osd_connect_device;

//显示尺寸
typedef enum
{
    osd_display_1080p = 1,
    osd_display_1920x1200
} osd_display_set;

//OSD 系统设置信息
typedef struct osd_system_set_info
{
    int system_reset;
    int software_upgrade;
    int language;
}osd_system_set_info;

//osd信息
typedef struct osd_info
{
    int main_id;
    int main_select;
    int mid_id;
    int mid_select;
    int sub_id;
    int sub_select;
    /////////
    osd_image_set_info 		image_set;   		//图像设置      7       7
    osd_mask_mode 			mask_mode;        	//图像遮蔽      4       0
    osd_rote_mode 			rote_mode;          //图像旋转              4
    osd_mirror_mode 		mirror_mode;        //图像镜像              4
    osd_scale_mode 			scale_mode;      	//图像缩放      4       0
    osd_led_level_info 		led_level;   		//照明设置      2       1
    osd_connect_device 		connect_device;		//连接设置      4       0
    osd_display_set 		display_set;    	//显示设置      3       0
    time_stamp      		time_set;       	//时间设置      6       6
    osd_system_set_info 	system_set; 		//系统设置      3       3
}osd_info;

//一级菜单
typedef struct mainpage_info
{
    GUI_CONST_STORAGE GUI_BITMAP *picselect;		//选中一级菜单的图标
    GUI_CONST_STORAGE GUI_BITMAP *picunselect;	    //未选中一级菜单的图标
    int pic_x;										//图标 X 轴起始点
    char *text;										//文字内容
    int pos_x;										//文字 X 轴起始点
    int pos_y;										//方框 Y 轴起始点
    int text_y;										//文字 Y 轴起始点
}mainpage_info;

//二级菜单
typedef struct midpage_info
{
    int pos_x;										//二级菜单方框 X 轴起始点
    int pos_y[10];									//二级菜单方框 Y 轴起始点
    int text_y[10];									//二级菜单文字 Y 轴起始点
    char *text[10];									//二级菜单 文字信息
    int length;										//三级子菜单数量
}midpage_info;

//三级菜单
typedef struct subpage_info
{
    int pos_x;
    int pos_y[10];
    int text_y[10];
    int length;
}subpage_info;

//存储空间
typedef struct disk_info
{
    double total;
    double used;
    double remain;
    double free;
}disk_info;

extern int copyefile;                                       //1=U盘拷贝状态,0=非拷贝状态:   定义在platform.c
extern int photo;					                        //1=拍照状态,0=非拍照状态：	定义在camera_thread.c
extern int video_freeze_state;                              //1=冻结状态,0=非冻结状态: 	定义在platform.c
extern int record;                                          //1=录像状态,0=非录像状态: 	定义在platform.c
extern int nosignal;                                        //1=无信号状态,0=有信号状态: 定义在platform.c
extern int MWB_State;                                       //1=白平衡状态,0=非白平衡状态;  定义在platform.c
extern int delete_file;                                     //1=正在删除状态,0=删除完毕状态;  定义在platform.c

extern int language;
extern unsigned char ucguiBuf[1920*1080*4];
extern GUI_FLASH const GUI_FONT GUI_FontHZ_SimSun_20;
extern GUI_FLASH const GUI_FONT GUI_FontHZ_SimSun_21;
extern GUI_FLASH const GUI_FONT GUI_FontHZ_SimSun_24;
extern GUI_FLASH const GUI_FONT GUI_FontHZ_SimSun_29;
extern GUI_FLASH const GUI_FONT GUI_FontHZ_SimSun_32;
extern GUI_FLASH const GUI_FONT GUI_FontHZ_SimSun_35;
extern GUI_FLASH const GUI_FONT GUI_FontHZ_SimSun_48;
extern osd_info global_osd_info;
extern pthread_mutex_t osd_mutex;
void VSB_osd_init();
void osd_process(int key);
void VSB_osd_display(int main_id,int main_select,int mid_id,int mid_select,int sub_id,int sub_select);
void VSB_osd_flush_cache(pthread_mutex_t * mutex);
void VSB_osd_exit();
void save_time();
void VSB_osd_update();
void read_osd_parameter();
void VSB_osd_parameter_default();
#endif /* OSD_H_ */
